﻿@model Admin.Models.ViewModel
<div class="container">
    <!-- Table -->
    <div class="row">
        <div class="col-md-12">
            <div class="widget">
                <div class="widget-head">
                    <div class="pull-left">
                        Available Companies</div>
                    <div class="widget-icons pull-right">
                        <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a><a href="#" class="wclose">
                            <i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix">
                    </div>
                </div>
                <div class="widget-content">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>
                                    #
                                </th>
                                <th>
                                    CID
                                </th>
                                <th>
                                    Name
                                </th>
                                <th>
                                    URL Domain
                                </th>
                                <th>
                                    Default Version
                                </th>
                                <th>
                                    Startup Site
                                </th>
                                <th>
                                    Created
                                </th>
                                <th>
                                    Modified
                                </th>
                                <th>
                                    Control
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (Model.Companies != null)
                            {
                                for (int i = 0; i < Model.Companies.Count; i++)
                                {
                                <tr>
                                    <td>@(i + 1)
                                    </td>
                                    <td>@Model.Companies[i].CID
                                    </td>
                                    <td>@Html.ActionLink(Model.Companies[i].Name, "index", "version", new { id = Model.Companies[i].CID }, null)
                                    </td>
                                    <td>@Model.Companies[i].Domain
                                    </td>
                                    <td>@Model.Companies[i].DefaultVersion
                                    </td>
                                    <td>@Model.Companies[i].StartUp
                                    </td>
                                    <td>@Model.Companies[i].CreatedDate
                                    </td>
                                    <td>@Model.Companies[i].ModifiedDate
                                    </td>
                                    <td>
                                        <button class="btn btn-xs btn-default">
                                            <i class="icon-ok"></i>
                                        </button>
                                        <button class="btn btn-xs btn-default">
                                            <i class="icon-pencil"></i>
                                        </button>
                                        <button class="btn btn-xs btn-default">
                                            <i class="icon-remove"></i>
                                        </button>
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                    <div class="widget-foot">
                        <ul class="pagination pull-right">
                            <li><a href="#">Prev</a></li>
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">Next</a></li>
                        </ul>
                        <div class="clearfix">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @*<div class="row">
        <div class="col-md-12">
            <div class="widget">
                <div class="widget-head">
                    <div class="pull-left">Versions</div>
                    <div class="widget-icons pull-right">
                        <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                        <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="widget-content">
                    <div class="padd">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>CID</th>
                                    <th>Name</th>
                                    <th>Pages</th>
                                    <th>Version HTML</th>
                                    <th>Files</th>
                                    <th>Global Plugins</th>
                                    <th>Is Default</th>
                                    <th>Created</th>
                                    <th>Modified</th>
                                    <th>Control</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if (Model.Versions != null)
                                {
                                    for (int i = 0; i < Model.Versions.Count; i++)
                                    {
                                        <tr>
                                            <td>@(i + 1)</td>
                                            <td>@Model.Versions[i].CID</td>
                                            <td>@Model.Versions[i].VersionName</td>
                                            <td>@(Model.Versions[i].Pages != null ? Model.Versions[i].Pages.Count : 0)</td>
                                            <td>
                                                <a href="#versionhtml@(i)" role="button" data-toggle="modal">View HTML</a>
                                            </td>
                                            <td>@(Model.Versions[i].FileIncludes != null ? Model.Versions[i].FileIncludes.Count : 0)</td>
                                            <td>@(Model.Versions[i].GlobalPlugins != null ? Model.Versions[i].GlobalPlugins.Count : 0)</td>
                                            <td>@Model.Versions[i].IsDefault</td>
                                            <td>@Model.Versions[i].CreatedDate</td>
                                            <td>@Model.Versions[i].ModifiedDate</td>
                                            <td>
                                                <button class="btn btn-xs btn-default"><i class="icon-ok"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-pencil"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-remove"></i></button>
                                            </td>
                                            <div id="versionhtml@(i)" class="modal fade">
                                                <div class="modal-dialog">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                            <h4>Version HTML</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="form">
                                                                @Model.Versions[i].VersionHTML
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </tr>
                                    }
                                }

                            </tbody>
                        </table>
                        <div class="widget-foot">
                            <ul class="pagination pull-right">
                                <li><a href="#">Prev</a></li>
                                <li><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">Next</a></li>
                            </ul>

                            <div class="clearfix"></div>
                        </div>

                    </div>
                    <div class="widget-foot">
                        <!-- Footer goes here -->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="widget">
                <div class="widget-head">
                    <div class="pull-left">Pages</div>
                    <div class="widget-icons pull-right">
                        <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                        <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="widget-content">
                    <div class="padd">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Page Name</th>
                                    <th>Version HTML</th>
                                    <th>Files</th>
                                    <th>Plugins</th>
                                    <th>Created</th>
                                    <th>Modified</th>
                                    <th>Control</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if (Model.Pages != null)
                                {
                                    for (int i = 0; i < Model.Pages.Count; i++)
                                    {
                                        <tr>
                                            <td>@(i + 1)</td>
                                            <td>@Model.Pages[i].PageName</td>
                                            <td> <a href="#pagehtml@(i)" role="button" data-toggle="modal">View HTML</a></td>
                                            <td>@(Model.Pages[i].FileIncludes != null ? Model.Pages[i].FileIncludes.Count : 0)</td>
                                            <td>@(Model.Pages[i].Plugins != null ? Model.Pages[i].Plugins.Count : 0)</td>
                                            <td>@Model.Pages[i].CreatedDate</td>
                                            <td>@Model.Pages[i].ModifiedDate</td>
                                            <td>
                                                <button class="btn btn-xs btn-default"><i class="icon-ok"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-pencil"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-remove"></i></button>
                                            </td>
                                        </tr>
                                        <div id="pagehtml@(i)" class="modal fade">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                        <h4>Page HTML</h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <div class="form">
                                                            @Model.Pages[i].VersionHTML
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                    }
                                }
                            </tbody>
                        </table>
                        <div class="widget-foot">
                            <ul class="pagination pull-right">
                                <li><a href="#">Prev</a></li>
                                <li><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">Next</a></li>
                            </ul>

                            <div class="clearfix"></div>
                        </div>

                    </div>
                    <div class="widget-foot">
                        <!-- Footer goes here -->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <div class="widget">
                <div class="widget-head">
                    <div class="pull-left">Plugins</div>
                    <div class="widget-icons pull-right">
                        <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                        <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="widget-content">
                    <div class="padd">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Plugin Name</th>
                                    <th>Modes</th>
                                    <th>Default Mode</th>
                                    <th>Is Active</th>
                                    <th>Created</th>
                                    <th>Modified</th>
                                    <th>Control</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if (Model.Plugins != null)
                                {
                                    for (int i = 0; i < Model.Plugins.Count; i++)
                                    {
                                        <tr>
                                            <td>@(i + 1)</td>
                                            <td>@Model.Plugins[i].PluginName</td>
                                            <td>@(Model.Plugins[i].Modes != null ? Model.Plugins[i].Modes.Count : 0)</td>
                                            <td>@(string.IsNullOrEmpty(Model.Plugins[i].Mode) ? "" : Model.Plugins[i].Mode)</td>
                                            <td>@Model.Plugins[i].IsActive</td>
                                            <td>@Model.Plugins[i].CreatedDate</td>
                                            <td>@Model.Plugins[i].ModifiedDate</td>
                                            <td>
                                                <button class="btn btn-xs btn-default"><i class="icon-ok"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-pencil"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-remove"></i></button>
                                            </td>
                                        </tr>
                                    }
                                }
                            </tbody>
                        </table>
                        <div class="widget-foot">
                            <ul class="pagination pull-right">
                                <li><a href="#">Prev</a></li>
                                <li><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">Next</a></li>
                            </ul>

                            <div class="clearfix"></div>
                        </div>

                    </div>
                    <div class="widget-foot">
                        <!-- Footer goes here -->
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="widget">
                <div class="widget-head">
                    <div class="pull-left">Files</div>
                    <div class="widget-icons pull-right">
                        <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                        <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="widget-content">
                    <div class="padd">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>File Name</th>
                                    <th>Type</th>
                                    <th>Sort order</th>
                                    <th>Created</th>
                                    <th>Modified</th>
                                    <th>Control</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if (Model.Includes != null)
                                {
                                    for (int i = 0; i < Model.Includes.Count; i++)
                                    {
                                        <tr>
                                            <td>@(i + 1)</td>
                                            <td>@Model.Includes[i].FileName</td>
                                            <td>@Model.Includes[i].Type</td>
                                            <td>@Model.Includes[i].SortOrder</td>
                                            <td>@Model.Includes[i].CreatedDate</td>
                                            <td>@Model.Includes[i].ModifiedDate</td>
                                            <td>
                                                <button class="btn btn-xs btn-default"><i class="icon-ok"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-pencil"></i></button>
                                                <button class="btn btn-xs btn-default"><i class="icon-remove"></i></button>
                                            </td>
                                        </tr>
                                    }
                                }
                            </tbody>
                        </table>
                        <div class="widget-foot">
                            <ul class="pagination pull-right">
                                <li><a href="#">Prev</a></li>
                                <li><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">Next</a></li>
                            </ul>

                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="widget-foot">
                        <!-- Footer goes here -->
                    </div>
                </div>
            </div>
        </div>
    </div>*@
</div>
<div id="createcompany" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="createcompanyLabel"
    aria-hidden="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    ×</button>
                <h4 class="modal-title">
                    Create Company</h4>
            </div>
            <div class="modal-body">
                <div class="matter">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-horizontal" data-control="CreateCompany">
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">
                                            Name</label>
                                        <div class="col-lg-8">
                                            <input type="text" data-name="Name" class="form-control" placeholder="Company Name">
                                            <input type="hidden" data-name="CID" value="@Model.Companies.Max(P => P.CID)" />
                                            <input type="hidden" data-name="_id" value="@MongoDB.Bson.ObjectId.GenerateNewId().ToString()" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">
                                            Default Version</label>
                                        <div class="col-lg-8">
                                            <select class="form-control" data-name="DefaultVersion">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">
                                            Start Up URL</label>
                                        <div class="col-lg-8">
                                            <input type="text" data-name="StartUp" class="form-control" placeholder="URL">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">
                    Close</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" data-action="CreateCompany">
                    Save changes</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var company = JSON.parse('@Html.Raw(Model.CompanyJson)');
</script>
